#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

typedef long long LL;

map<LL, int> mp;

const int N = 1505, K = 35;

int n, k;

char s[N][K];

LL trans(char s[], int len)
{
	const auto f = [](char ch)
	{
		switch (ch)
		{
		case 'S':
			return 0;
			break;
		case 'E':
			return 1;
			break;
		case 'T':
			return 2;
			break;
		default:
			break;
		}
		return 1;
	};
	LL res = 0;
	for (int i=0; i<len; ++i)
		res = res * 3 + f(s[i]);
	return res;
}

char exc(char a, char b)
{
	assert(a != b);
	const char *s = "SET";
	for (int i=0; i<3; ++i)
	{
		if (s[i] != a && s[i] != b) return s[i];
	}
	return s[0];
}

int main(int argc, char const *argv[])
{
	scanf("%d%d", &n, &k);

	for (int i=0; i<n; ++i)
	{
		scanf("%s", s[i]);
		mp[trans(s[i], k)]++;
	}

	LL ans = 0;

	for (int i=0; i<n; ++i)
		for (int j=i+1; j<n; ++j)
		{
			static char t[K];
			for (int l=0; l<k; ++l)
			{
				if (s[i][l] == s[j][l])
					t[l] = s[i][l];
				else
					t[l] = exc(s[i][l], s[j][l]);
			}
			ans += mp[trans(t, k)];
		}
	printf("%lld\n", ans / 3);
	return 0;
}